define(["app","js/signature/mainView","js/init", 'js/utils','js/util/socketUtil',"text!app/signature/main.html","js/signature/model"], 
	function(app, mainView,base,Utils,initSocket,source,model) {
	
	
	var bindings = [		
		{
			element: '.signature-page .type-link',
			event: 'click',
			handler: clickType
		}				
	];
	
	function clickType(e){


		if(!app.mainView){
			app = app.getApp();
		}

		
		
		var typeCode ,typeName
		if(e && e.currentTarget){
			typeCode = $(e.currentTarget).attr('pid')
			typeName = $(e.currentTarget).attr('pname')
		}
		
		
		if(typeCode){

			
			var _cv = app.f7.getCurrentView();			
			var _router
			if(_cv){
				_router = _cv.router			
			}else{
				_router = app.f7.views.risk.router			
			}
			
			app.f7.showPreloader('loading...');
			_router.load({url:'app/signature/type.html',query:{code:typeCode,name:typeName}});
			//_router.reloadPage('app/risk/'+typeCode + '.html');
		}
	}

	function init(query){	
		
		
		
		mainView.render({
			model	: model.type,
			bindings: bindings
		});
//		$('#signature-page .rb-grid').html(source);
			
		//signatureView.render({			
		//	bindings: bindings
		//});
	}
	

	return {
		init: init
	};
});